package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.IncomingInspection;
import com.tac.service.mes.IncomingInspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/incomingInspection")
@CrossOrigin
@Api(tags = "制造执行MES--质量管理--来料检验")
public class IncomingInspectionController {

    @Autowired
    private IncomingInspectionService incomingInspectionService;

    //来料检验查看
    @ApiOperation("来料检验查看")
    @GetMapping("/getList")
    public Result<PageInfo<IncomingInspection>> getList(Integer pageNum, Integer pageSize, Integer serialNumber, Integer materialApplicationId, Integer materialId, String inspector,
                                                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date inspectionTimeStart,@DateTimeFormat(pattern = "yyyy-MM-dd")  Date inspectionTimeEnd){
        return incomingInspectionService.getList(pageNum,pageSize,serialNumber,materialApplicationId,materialId,inspector,inspectionTimeStart,inspectionTimeEnd);
    }
    //来料检验添加
    @ApiOperation("来料检验添加")
    @PostMapping("/save")
    public Result save(@RequestBody IncomingInspection incomingInspection){
        return incomingInspectionService.save(incomingInspection);
    }
    //来料检验删除
    @ApiOperation("来料检验删除")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids){
        return incomingInspectionService.remove(ids);
    }
    //来料检验更新
    @ApiOperation("来料检验更新")
    @PutMapping("/update")
    public Result update(@RequestBody IncomingInspection incomingInspection){
        return incomingInspectionService.update(incomingInspection);
    }
}
